<?php
defined('IN_IA') or exit ('Access Denied');

class Core extends WeModuleSite
{
  
    public function getMainMenu()
    {
        global $_W, $_GPC;

        $do = $_GPC['do'];
        $navemenu = array();
        $cur_color = ' style="color:#d9534f;" ';
            $navemenu[0] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=menu&m=zh_yjm" class="panel-title wytitle" id="yframe-0"><icon style="color:#8d8d8d;" class="fa fa-bars"></icon>  底部自定义</a>',
                'items' => array(
                   0 => $this->createMainMenu('底部自定义 ', $do, 'menu', ''),
               )
            );
            $navemenu[1] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=banner&m=zh_yjm" class="panel-title wytitle" id="yframe-1"><icon style="color:#8d8d8d;" class="fa fa-info-circle"></icon>轮播图管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('轮播图管理', $do, 'banner', ''),
                )
            );
            $navemenu[2] = array(
               'title' => '<a href="index.php?c=site&a=entry&op=display&do=store&m=zh_yjm" class="panel-title wytitle" id="yframe-2"><icon style="color:#8d8d8d;" class="fa fa-map-marker"></icon>门店管理</a>',
               'items' => array(
                    0 => $this->createMainMenu('门店管理', $do, 'store', ''),
               )
            );
            $navemenu[3] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=storetype&m=zh_yjm" class="panel-title wytitle" id="yframe-3"><icon style="color:#8d8d8d;" class="fa fa-cubes"></icon>门店类型管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('门店类型管理', $do, 'storetype', ''),
                )
            );
            $navemenu[4] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=member&m=zh_yjm" class="panel-title wytitle" id="yframe-4"><icon style="color:#8d8d8d;" class="fa fa-user"></icon>会员管理</a>',
                'items' => array(
                    0 => $this->createMainMenu('会员管理', $do, 'member', ''),
                )
            );
            $navemenu[5] = array(
                'title' => '<a href="index.php?c=site&a=entry&op=display&do=user&m=zh_yjm" class="panel-title wytitle" id="yframe-5"><icon style="color:#8d8d8d;" class="fa fa-child"></icon>用户信息</a>',
                'items' => array(
                    0 => $this->createMainMenu('用户信息', $do, 'user', ''),
                )
            );
            // $navemenu[14] = array(
            //     'title' => '<a href="index.php?c=site&a=entry&op=display&do=peiz&m=zh_yjm" class="panel-title wytitle" id="yframe-14"><icon style="color:#8d8d8d;" class="fa fa-cog"></icon>  系统设置</a>',
            //     'items' => array(
            //         // 0 => $this->createMainMenu('基本信息 ', $do, 'settings', ''),
            //         1 => $this->createMainMenu('公众号配置', $do, 'peiz', ''),
            //         // 2 => $this->createMainMenu('支付配置', $do, 'pay', ''),
            //         // 3 => $this->createMainMenu('短信配置', $do, 'code', ''),                     
            //         // 4 => $this->createMainMenu('模板消息', $do, 'sms', ''),
            //         5 => $this->createMainMenu('logo设置', $do, 'logo', ''), 
            //         // 5 => $this->createMainMenu('帮助中心', $do, 'help', ''),                      
            //         // 4 => $this->createMainMenu('系统更新', $do, 'heli', ''),  
            //     )
            // );
        return $navemenu;
    }

    public function getNaveMenu()
    {
        global $_W, $_GPC;
        $do = $_GPC['do'];
        $navemenu = array();
        $cur_color = '#8d8d8d';
        $navemenu[0] = array(
            'title' => '<a href="zh_yjmcus.php?c=site&a=entry&do=cussell&m=zh_yjm" class="panel-title wytitle" id="yframe-0"><icon style="color:#8d8d8d;" class="fa fa-money"></icon>营业概览</a>',
            'items' => array(
                 0 => $this->createSubMenu('营业概览 ', $do, 'cussell', 'fa-angle-right', $cur_color,''),
            )
        );
        $navemenu[1] = array(
            'title' => '<a href="zh_yjmcus.php?c=site&a=entry&do=cusmember&m=zh_yjm" class="panel-title wytitle" id="yframe-1"><icon style="color:#8d8d8d;" class="fa fa-user"></icon>会员管理</a>',
            'items' => array(
                 0 => $this->createSubMenu('会员管理 ', $do, 'cusmember', 'fa-angle-right', $cur_color,''),
            )
        );
        $navemenu[2] = array(
            'title' => '<a href="zh_yjmcus.php?c=site&a=entry&do=projecttype&m=zh_yjm" class="panel-title wytitle" id="yframe-2"><icon style="color:#8d8d8d;" class="fa fa-server"></icon>项目类型管理</a>',
            'items' => array(
                0 => $this->createSubMenu('项目类型管理', $do, 'projecttype', 'fa-angle-right', $cur_color,''),
            )
        );
        $navemenu[3] = array(
            'title' => '<a href="zh_yjmcus.php?c=site&a=entry&do=project&m=zh_yjm" class="panel-title wytitle" id="yframe-3"><icon style="color:#8d8d8d;" class="fa fa-bars"></icon>项目管理</a>',
            'items' => array(
                0 => $this->createSubMenu('项目管理', $do, 'project', 'fa-angle-right', $cur_color,''),
            )
        );
        $navemenu[4] = array(
            'title' => '<a href="zh_yjmcus.php?c=site&a=entry&do=assistant&m=zh_yjm" class="panel-title wytitle" id="yframe-4"><icon style="color:#8d8d8d;" class="fa fa-child"></icon>店员管理</a>',
            'items' => array(
                0 => $this->createSubMenu('店员管理', $do, 'assistant', 'fa-angle-right', $cur_color,''),
            )
        );
        return $navemenu;
    }
    function createCoverMenu($title, $method, $op, $icon = "fa-image", $color = '#d9534f')
    {
        global $_GPC, $_W;
        $cur_op = $_GPC['op'];
        $color = ' style="color:'.$color.';" ';
        return array('title' => $title, 'url' => $op != $cur_op ? $this->createWebUrl($method, array('op' => $op)) : '',
            'active' => $op == $cur_op ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa fa-angle-right"></i>',
            )
        );
    }

    function createMainMenu($title, $do, $method, $icon = "fa-image", $color = '')
    {
        $color = ' style="color:'.$color.';" ';

        return array('title' => $title, 'url' => $do != $method ? $this->createWebUrl($method, array('op' => 'display')) : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i '.$color.' class="fa fa-angle-right"></i>',
            )
        );
    }

  /*  function createSubMenu($title, $do, $method, $icon = "fa-image", $color = '#d9534f', $storeid)
    {
        $color = ' style="color:'.$color.';" ';
        $url = $this->createWebUrl($method, array('op' => 'display', 'storeid' => $storeid));
        if ($method == 'stores') {
            $url = $this->createWebUrl('stores', array('op' => 'post', 'id' => $storeid, 'storeid' => $storeid));
        }

        return array('title' => $title, 'url' => $do != $method ? $url : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa '.$icon.'"></i>',
            )
        );
    }

*/
    function createWebUrl2($do, $query = array()) {
        $query['do'] = $do;
        $query['m'] = strtolower($this->modulename);
      
        return $this->wurl('site/entry', $query);
    }

    function wurl($segment, $params = array()) {
      
        list($controller, $action, $do) = explode('/', $segment);
        $url = './zh_yjmcus.php?';
        if (!empty($controller)) {
            $url .= "c={$controller}&";
        }
        if (!empty($action)) {
            $url .= "a={$action}&";
        }
        if (!empty($do)) {
            $url .= "do={$do}&";
        }
        if (!empty($params)) {
            $queryString = http_build_query($params, '', '&');
            $url .= $queryString;
        }
        return $url;
    }

        function createSubMenu($title, $do, $method, $icon = "fa-image", $color = '#d9534f', $storeid)
    {
        $color = ' style="color:'.$color.';" ';
        $url = $this->createWebUrl2($method, array('op' => 'display', 'storeid' => $storeid));
        if ($method == 'stores2') {
            $url = $this->createWebUrl2('stores2', array('op' => 'post', 'id' => $storeid, 'storeid' => $storeid));
        }



        return array('title' => $title, 'url' => $do != $method ? $url : '',
            'active' => $do == $method ? ' active' : '',
            'append' => array(
                'title' => '<i class="fa '.$icon.'"></i>',
            )
        );
    }
    public function getStoreById($id)
    {
        $store = pdo_fetch("SELECT * FROM " . tablename('wpdc_store') . " WHERE id=:id LIMIT 1", array(':id' => $id));
        return $store;
    }


    public function set_tabbar($action, $storeid)
    {
        $actions_titles = $this->actions_titles;
        $html = '<ul class="nav nav-tabs">';
        foreach ($actions_titles as $key => $value) {
            if ($key == 'stores') {
                $url = $this->createWebUrl('stores', array('op' => 'post', 'id' => $storeid));
            } else {
                $url = $this->createWebUrl($key, array('op' => 'display', 'storeid' => $storeid));
            }

            $html .= '<li class="' . ($key == $action ? 'active' : '') . '"><a href="' . $url . '">' . $value . '</a></li>';
        }
        $html .= '</ul>';
        return $html;
    }
}